Skip to content

bench: refactor random number generation in stats/base/dists/weibull #5217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

G4URAV001
Copy link
Contributor

@G4URAV001 G4URAV001 commented Feb 14, 2025

Resolves #4992 .

Description

This pull request:

This pull request improves random number generation in JS benchmarks for stats/base/dists/weibull. Specifically:

Moves random number generation out of benchmarking loops to prevent interference with benchmark results.

Uses @stdlib/random/base/uniform and @stdlib/random/base/discrete-uniform instead of randu expressions.

Ensures generated random values maintain the same range as existing values for consistency.

Related Issues

Does this pull request have any related issues?

References #4837 and #4955 as examples of similar improvements.

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

✅ Build Native Add-on.
✅ Run JavaScript Benchmarks.
✅ Run JavaScript Native Benchmarks.


@stdlib-js/reviewers

… in JS benchmarks

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
… JS benchmarks

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels Feb 14, 2025
@G4URAV001 G4URAV001 closed this Feb 14, 2025
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Feb 14, 2025
@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/triangular/cdf $\color{green}271/271$
$\color{green}+100.00\%$
$\color{green}34/34$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}271/271$
$\color{green}+100.00\%$
stats/base/dists/triangular/ctor $\color{red}520/524$
$\color{green}+99.24\%$
$\color{red}56/57$
$\color{green}+98.25\%$
$\color{red}20/21$
$\color{green}+95.24\%$
$\color{red}520/524$
$\color{green}+99.24\%$
stats/base/dists/triangular/entropy $\color{green}206/206$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}206/206$
$\color{green}+100.00\%$
stats/base/dists/triangular/kurtosis $\color{green}205/205$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}205/205$
$\color{green}+100.00\%$
stats/base/dists/triangular/logcdf $\color{green}275/275$
$\color{green}+100.00\%$
$\color{green}34/34$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}275/275$
$\color{green}+100.00\%$
stats/base/dists/triangular/logpdf $\color{green}362/362$
$\color{green}+100.00\%$
$\color{green}39/39$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}362/362$
$\color{green}+100.00\%$
stats/base/dists/triangular/mean $\color{green}189/189$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}189/189$
$\color{green}+100.00\%$
stats/base/dists/triangular/median $\color{red}195/197$
$\color{green}+98.98\%$
$\color{red}12/13$
$\color{green}+92.31\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{red}195/197$
$\color{green}+98.98\%$
stats/base/dists/triangular/mgf $\color{red}344/348$
$\color{green}+98.85\%$
$\color{red}25/27$
$\color{green}+92.59\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{red}344/348$
$\color{green}+98.85\%$
stats/base/dists/triangular/mode $\color{green}189/189$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}189/189$
$\color{green}+100.00\%$
stats/base/dists/triangular/pdf $\color{green}348/348$
$\color{green}+100.00\%$
$\color{green}39/39$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}348/348$
$\color{green}+100.00\%$
stats/base/dists/triangular/quantile $\color{green}273/273$
$\color{green}+100.00\%$
$\color{green}33/33$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}273/273$
$\color{green}+100.00\%$
stats/base/dists/triangular/skewness $\color{green}210/210$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}210/210$
$\color{green}+100.00\%$
stats/base/dists/triangular/stdev $\color{green}206/206$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}206/206$
$\color{green}+100.00\%$
stats/base/dists/triangular/variance $\color{green}197/197$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}197/197$
$\color{green}+100.00\%$
stats/base/dists/weibull/cdf $\color{green}298/298$
$\color{green}+100.00\%$
$\color{green}25/25$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}298/298$
$\color{green}+100.00\%$
stats/base/dists/weibull/ctor $\color{red}486/487$
$\color{green}+99.79\%$
$\color{green}33/33$
$\color{green}+100.00\%$
$\color{red}18/19$
$\color{green}+94.74\%$
$\color{red}486/487$
$\color{green}+99.79\%$
stats/base/dists/weibull/entropy $\color{green}126/126$
$\color{green}+100.00\%$
$\color{green}8/8$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}126/126$
$\color{green}+100.00\%$
stats/base/dists/weibull/kurtosis $\color{green}137/137$
$\color{green}+100.00\%$
$\color{green}8/8$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}137/137$
$\color{green}+100.00\%$
stats/base/dists/weibull/logcdf $\color{green}311/311$
$\color{green}+100.00\%$
$\color{green}28/28$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}311/311$
$\color{green}+100.00\%$
stats/base/dists/weibull/logpdf $\color{green}308/308$
$\color{green}+100.00\%$
$\color{green}35/35$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}308/308$
$\color{green}+100.00\%$
stats/base/dists/weibull/mean $\color{green}195/195$
$\color{green}+100.00\%$
$\color{green}10/10$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}195/195$
$\color{green}+100.00\%$
stats/base/dists/weibull/median $\color{green}197/197$
$\color{green}+100.00\%$
$\color{green}10/10$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}197/197$
$\color{green}+100.00\%$
stats/base/dists/weibull/mgf $\color{red}262/264$
$\color{green}+99.24\%$
$\color{red}23/25$
$\color{green}+92.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{red}262/264$
$\color{green}+99.24\%$
stats/base/dists/weibull/mode $\color{green}128/128$
$\color{green}+100.00\%$
$\color{green}10/10$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}128/128$
$\color{green}+100.00\%$
stats/base/dists/weibull/pdf $\color{green}310/310$
$\color{green}+100.00\%$
$\color{green}36/36$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}310/310$
$\color{green}+100.00\%$
stats/base/dists/weibull/quantile $\color{green}218/218$
$\color{green}+100.00\%$
$\color{green}23/23$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}218/218$
$\color{green}+100.00\%$
stats/base/dists/weibull/skewness $\color{green}139/139$
$\color{green}+100.00\%$
$\color{green}8/8$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}139/139$
$\color{green}+100.00\%$
stats/base/dists/weibull/stdev $\color{green}128/128$
$\color{green}+100.00\%$
$\color{green}8/8$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}128/128$
$\color{green}+100.00\%$
stats/base/dists/weibull/variance $\color{green}128/128$
$\color{green}+100.00\%$
$\color{green}8/8$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}128/128$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Statistics Issue or pull request related to statistical functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: Refactor random number generation in JS benchmarks for stats/base/dists/weibull
2 participants